package com.hrsystem.mapper;

import com.hrsystem.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserMapper {

    /**
     * 登录sql
     * @param account
     * @return
     */
//    @Select("select * from t_user where account = #{account}")
    User getUserByAccount(String account);

    /**
     * 注册sql
     * @param user
     * @return
     */
//    @Insert("insert into t_user (name, account, password) values ( #{name}, #{account}, #{password})")
    int register(User user);

    /**
     * 登录时获取新生成的token
     * @param token
     * @param id
     * @return
     */
//    @Update("update t_user set token = #{token} where id = #{id}")
    int setTokenToUser(@Param("token") String token, @Param("id") Integer id);

//    @Select("select * from t_user where token = #{token}")
    User getUserByToken(String token);
}
